<?php
class Soul_Request_Http_Response{

    protected $content = '';

    public function setHeader($header){
        header($header);
        return $this;
    }

    public function redirect($url){
        header("location:$url");
        $this->end();
    }

    public function getContent(){
        return $this->content;
    }
    public function setContent($value){
    	$this->content = $value;
    	return $this;
    }

    public function write($content){
        $this->content .= $content;
        return $this;
    }

    public function clear(){
        $this->content = '';
        return $this;
    }
    
    public function output(){
        if(Soul_Util_Enviroment::extensionIsLoaded('zlib') && strstr($_SERVER["HTTP_ACCEPT_ENCODING"],"gzip")){
            ob_start("ob_gzhandler");
        }
        echo $this->content;
        if(Soul_Util_Enviroment::extensionIsLoaded('zlib')){
            ob_end_flush();
        }
    }    

    public function flush(){
        $this->output();
        $this->clear();
        return $this;
    }

    public function end(){
        exit;
    }
}